package com.doraemon.controller.admin;

import com.doraemon.result.Result;
import com.doraemon.service.WorkSpaceService;
import com.doraemon.vo.BusinessDataVO;
import com.doraemon.vo.DishOverViewVO;
import com.doraemon.vo.OrderOverViewVO;
import com.doraemon.vo.SetmealOverViewVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * 工作台管理Controller
 **/
@RestController
@RequestMapping("/admin/workspace")
@Slf4j
@Api(tags = "工作台相关接口")
public class WorkSpaceController {

    @Autowired
    private WorkSpaceService workSpaceService;

    /***
     * 查询今日运营数据
     * ---
     * @return: com.doraemon.result.Result<com.doraemon.vo.BusinessDataVO>
     */
    @GetMapping("/businessData")
    @ApiOperation("查询今日运营数据")
    public Result<BusinessDataVO> businessData() {

        // 获取当天开始和结束时间
        LocalDateTime begin = LocalDateTime.now().with(LocalTime.MIN);
        LocalDateTime end = LocalDateTime.now().with(LocalTime.MAX);

        // 调用Service层，获取运营数据VO类
        BusinessDataVO businessDataVO = workSpaceService.getBusinessData(begin, end);

        return Result.success(businessDataVO);
    }

    /***
     * 查询订单管理数据
     * ---
     * @return: com.doraemon.result.Result<com.doraemon.vo.OrderOverViewVO>
     */
    @GetMapping("/overviewOrders")
    @ApiOperation("查询订单管理数据")
    public Result<OrderOverViewVO> orderOverView() {

        // 调用Service层，获取订单管理数据VO类
        OrderOverViewVO orderOverViewVO = workSpaceService.getOrderOverView();

        return Result.success(orderOverViewVO);
    }

    /***
     * 查询菜品总览
     * ---
     * @return: com.doraemon.result.Result<com.doraemon.vo.DishOverViewVO>
     */
    @GetMapping("/overviewDishes")
    @ApiOperation("查询菜品总览")
    public Result<DishOverViewVO> dishOverView() {

        // 调用Service层，获取菜品总览VO类
        DishOverViewVO dishOverViewVO = workSpaceService.getDishOverView();

        return Result.success(dishOverViewVO);
    }

    /***
     * 查询套餐总览
     * ---
     * @return: com.doraemon.result.Result<com.doraemon.vo.SetmealOverViewVO>
     */
    @GetMapping("/overviewSetmeals")
    @ApiOperation("查询套餐总览")
    public Result<SetmealOverViewVO> setmealOverView() {

        // 调用Service层，获取套餐总览VO类
        SetmealOverViewVO setmealOverViewVO = workSpaceService.getSetmealOverView();

        return Result.success(setmealOverViewVO);
    }

}
